import torch
import pandas as pd

# 1. 读取
predall, yall = torch.load('./result/CNN_1')

# 2. 转为numpy（假设是tensor；如果已经是numpy或list则不用这一步）
predall = predall.cpu().numpy() if hasattr(predall, 'cpu') else predall
yall = yall.cpu().numpy() if hasattr(yall, 'cpu') else yall

# 3. 合成DataFrame
df = pd.DataFrame({
    'pred': predall.flatten(),
    'label': yall.flatten()
})

# 4. 保存为csv
df.to_csv('./result/CNN_1.csv', index=False)

print('保存完毕')